﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CoreInmobiliario.Frontend
{
    public partial class CoreInmobiliario : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckPermission();
        }

        public void CheckPermission()
        {
            if (Session[HelperClasses.Parameters.USERID] != null)
            {
                if (Session[HelperClasses.Parameters.USERNAME] != null)
                {
                    lblUserName.Text = Session[HelperClasses.Parameters.USERNAME].ToString();
                    panelUserName.Visible = true;
                }
            }
        }

        public string GetPanelAdministration()
        {
            string item = "";

            if (Session[HelperClasses.Parameters.USERID] != null)
            {
                if (Session[HelperClasses.Parameters.USERNAME] != null)
                {
                    item = "" +
                        "<li>" +
                        "    <a href='Propiedades.aspx'>Administración</a>" +
                        "    <ul>" +
                        "        <li><a href='Propiedad.aspx'>Nueva Propiedad</a></li>" +
                        "        <li><a href='Propiedades.aspx'>Propiedades</a></li>" +
                        "        <li><a href='Horarios.aspx'>Horarios</a></li>" +
                        "    </ul>" +
                        "</li>";
                }
            }

            return item;
        }

        protected void btnSalir_Click(object sender, EventArgs e)
        {
            Session.Remove(HelperClasses.Parameters.USERID);
            Session.Remove(HelperClasses.Parameters.USERNAME);
            panelUserName.Visible = false;

            Response.Redirect(HttpContext.Current.Request.Url.LocalPath);
        }
    }
}